package file;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class Test10 {
    public static void main(String[] args)
    {
        Scanner input=new Scanner(System.in);
        FileWriter fw=null;
        try
        {
            fw=new FileWriter("/home/ken/Desktop/pkgUpload.js");    //创建FileWriter对象
            for(int i=0;i<4;i++)
            {
                System.out.println("请输入第"+(i+1)+"个字符串：");
                String name=input.next();    //读取输入的名称
                fw.write(name+"\r\n");    //循环写入文件
            }
            System.out.println("录入完成！");
        }
        catch(Exception e)
        {
            System.out.println(e.getMessage());
        }
        finally
        {
            try
            {
                fw.close();    //关闭对象
            }
            catch(IOException e)
            {
                e.printStackTrace();
            }
        }
    }
}
